<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript"  src="${ctx}/scripts/common/prototype.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/validation/validation.js"></script>

<link href="${ctx}/scripts/jscalendar-1.0/calendar-blue2.css" rel="stylesheet" type="text/css">
<script language="JavaScript"  src="${ctx}/scripts/jscalendar-1.0/calendar.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/jscalendar-1.0/lang/calendar-en.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/jscalendar-1.0/calendar-setup.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script>
	var ACTION_URL="${ctx}/house_companyAction.do?";
	var sourceValue;


	//修改
	function edit(){
		var url= ACTION_URL + "method=editCompany";
		var pars=$('fcompany').serialize();
		//校验
		var isTure= $("fcompany").fireEvent("onSubmit");
		//ajax提交
		if(isTure){
			closeORopenButton();
		//			alert(url);
			var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: showResponseEdit}
		                    );
		}
	}

	//修改操作的响应
	function showResponseEdit(result){
		var obj=findFrame('main');
		var companyVO=eval('('+result.responseText+')');
		obj.refreshTree(companyVO.name);
		closeORopenButton();
		ajaxSubmitException(result.responseText);
		windowClose();
	}

	function init(){
		sourceValue=$('fcompany').serialize();
		Event.observe('btn1_22','click',edit);
		//$('name').validateUrl=ACTION_URL + "method=checkManageOrgName";
	}

	//如果内容有修改，则先提示是否关闭
	function closeWin(){
		var newValue=$('fcompany').serialize();
		if(sourceValue==newValue){
			windowClose();
		}else{
			AskConfirmTwo('${key.tipsForCloseWindow}',"companyEditIFrame","afterCloseDo","windowClose");
		}
	}

	//关闭窗口前执行的动作
	function afterCloseDo(){
		edit();
	}

	//关闭或打开按钮事件
	function closeORopenButton(){
		$('window_footer').disabled= !$('window_footer').disabled;
		$('btn1_22').disabled= !$('btn1_22').disabled;
		$('btn1_32').disabled= !$('btn1_32').disabled;
	}
</script>
</head>

<body onload="init();">
<form action="" name="fcompany" method="post" class="required-validate required">
<input type="hidden" name="keyword" value="${companyVO.keyword}">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"> <span class="window_head_intext">${key.modifyCompany}</span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td valign="middle" class="content"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="container_in_show">
      <tr>
        <td valign="top">
        <div id="tab_Search" >
              <table width="100%" border="0" cellpadding="0" cellspacing="0" id="tab_subMenu1">
                <tr>
                  <td><table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">

                      <tr>
                        <td><table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
                          <tr>
                            <td  class="aux_intable_td1">${key.name}：</td>
                            <td  class="aux_intable_require"><input name="name" type="text" class="inputtext required validate-char" value="${companyVO.name}" size="16"> </td>
                            </tr>
                          <tr>
                            <td class="aux_intable_td1">${key.corporation}：</td>
                            <td class="aux_intable_td2"><input name="corporation" type="text" class="inputtext validate-char" value="${companyVO.corporation}" size="16"></td>
                            </tr>
                          <tr>
                            <td class="aux_intable_td1">${key.establishDate}：</td>
                            <td class="aux_intable_td2"><table border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td><input name="establishDate" type="text" class="inputtext validate-date-yyyy-mm-dd" value="${companyVO.establishDate}" size="16"></td>
                                <td width="4">&nbsp;</td>
                                <td><img src="${ctx}/images/ico_clock.gif"  id="establishDateButton" width="20" height="20"></td>
                              </tr>
                            </table></td>
                            </tr>
                          <tr>
                            <td valign="top" class="aux_intable_td1">${key.qualify}：</td>
                            <td valign="top" class="aux_intable_td2"><mypms:Sysrefcode name="qualifyId" selectValue="${companyVO.qualifyId}" style="width:110" code="HM_COMPANY_LONGEVITY_LEVEL"></mypms:Sysrefcode> </td>
                          </tr>
                          <tr>
                            <td valign="top" class="aux_intable_td1">${key.acreage}：</td>
                            <td valign="top" class="aux_intable_td2"><input name="acreage" type="text" class="inputtext validate-pattern-/^(0|([1-9]\d{0,9}))(\.\d{1,2})?$/g" style="text-align:right" value="${companyVO.acreage}" size="16">
                              ㎡</td>
                            </tr>
                          <tr>
                            <td valign="top" class="aux_intable_td1">${key.address}：</td>
                            <td valign="top" class="aux_intable_td2"><input name="address" type="text" class="inputtext validate-char" value="${companyVO.address}" size="16">                            </td>
                            </tr>


                        </table></td>
                      </tr>

                  </table></td>
                </tr>
              </table>

			</div>
			</div>
		  </td>
      </tr>
    </table>

	</td>
  </tr>
  <tr>
    <td class="window_footer" id="window_footer"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0" >
            <tr>
			  <td>&nbsp;</td>
			  <td class="btn_between_space"></td>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onblur="btn_change(2)" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onClick="closewin();"><img src="${ctx}/images/ico_ok.gif" border="0" align="absmiddle" /> ${key.save}</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onclick="closeWin();" onblur="btn_change(3)" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)"><img src="${ctx}/images/ico_cancel.gif" border="0" align="absmiddle" /> ${key.close}</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<script type="text/javascript">
              Calendar.setup(
              {
	              inputField : "establishDate", // ID of the input field
	              ifFormat : "%Y-%m-%d", // the date format
	              button : "establishDateButton", // ID of the button
	              align          :    "Tl",           // alignment (defaults to "Bl")
			      singleClick    :    true
              }
              );
</script>
</form>
</body>
</html>